package com.jcf.springboot.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jcf.springboot.entity.business.Member;
import com.jcf.springboot.mapper.MemberMapper;
import com.jcf.springboot.security.util.JwtUtil;
import com.jcf.springboot.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.Map;


/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jjj
 * @since 2021-03-15
 */
@Service
public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> implements MemberService {

  @Autowired
  private JwtUtil jwtUtil;
  @Autowired
  private MemberMapper memberMapper;
  @Override
  public Map sealData(Member one) {
      String username = one.getMemberName();


      String token = jwtUtil.generateToken(username);

      HashMap<Object, Object> map = new HashMap<>();
      map.put("authorization", token);
      map.put("userInfo",one);
      return map;
    }

  @Override
  @Transactional
  public Boolean updateMember(Member member) {
    int i = memberMapper.updateById(member);
    if(i > 0){
      return true;
    }
    return false;
  }



}
